#define _CRT_SECURE_NO_WARNINGS 1

#include "sort.h"

void TestInsertSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("InsertSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestShellSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("ShellSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestBubbleSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("BubbleSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	BubbleSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestSelectSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("SelectSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	SelectSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestHeapSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("HeapSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	HeapSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestQuickSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("QuickSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	QuickSort(a, 0, sizeof(a) / sizeof(int) - 1);
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestQuickSort_NonR()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("QuickSort_NonR\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	QuickSort_NonR(a, 0, sizeof(a) / sizeof(int) - 1);
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestQuickSort_3Line()
{
	int a[] = { 6,9,6,4,6,8,6,3,6 };
	printf("QuickSort_3Line\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	QuickSort_3Line(a, 0, sizeof(a) / sizeof(int) - 1);
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestMergeSort()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("MergeSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	MergeSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestMergeSort_NonR()
{
	int a[] = { 5,9,1,4,6,8,7,3,2 };
	printf("MergeSort_NonR\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	MergeSort_NonR(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

void TestCountSort()
{
	int a[] = { 102,105,103,100,102,103,100,103 };
	printf("CountSort\n");
	PrintArray(a, sizeof(a) / sizeof(int));
	CountSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
	printf("\n");
}

int main()
{
	TestInsertSort();
	TestShellSort();
	TestBubbleSort();
	TestSelectSort();
	TestHeapSort();
	TestQuickSort();
	TestQuickSort_NonR(); 
	TestQuickSort_3Line();
	TestMergeSort();
	TestMergeSort_NonR();
	TestCountSort();
	return 0;
}